import os
from google.appengine.api import urlfetch
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from tmdb import TMDb
from models import *
from mainpage import MainPage
from aboutpage import AboutPage
from shelfpages import *
from moviepages import *

application = webapp.WSGIApplication([('/', MainPage),
                                      ('/about/', AboutPage),
                                      ('/movie/search', MovieSearchPage),
                                      ('/movie/search/(.*)', MovieSearchResultsPage),
                                      ('/shelf/list', ShelfListPage),
                                      ('/shelf/list/(.*)', ShelfListOrderedPage),
                                      ('/shelf/add', ShelfAddPage),
                                      ('/shelf/(.*)/(.*)/delete', ShelfDeleteItemPage),
                                      ('/shelf/(.*)/(.*)/edit', ShelfEditItemPage),
                                      ('/meta/(.*)/edit', ShelfItemEditMetaPage),
                                      ('/meta/(.*)/delete', ShelfItemDeleteMetaPage),
                                      ('/shelf/(.*)/(.*)/meta/add', ShelfItemAddMetaPage),
                                      ('/shelf/(.*)/delete', ShelfDeletePage),
                                      ('/shelf/(.*)/edit', ShelfEditPage),
                                      ('/shelf/(.*)/add', ShelfAddItemPage),
                                      ('/shelf/(.*)/add/movie/meta/(.*)/(.*)', ShelfItemAddMovieMeta),
                                      ('/shelf/(.*)/add/movie/(.*)', ShelfAddMoviePage),
                                      ('/shelf/(.*)/(.*)', ShelfViewItemPage),
                                      ('/shelf/(.*)', ShelfViewPage)], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
